package com.bkgy.modular.configureRules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.modular.configureRules.dto.AcidRollingLMN1720Dto;
import com.bkgy.modular.configureRules.entity.AcidRollingLMN1720;
import com.bkgy.modular.configureRules.mapper.AcidRollingLMN1720Mapper;
import com.bkgy.modular.configureRules.service.AcidRollingLMN1720Service;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @ClassName AcidRollingLMN2130ServiceImpl
 * @date 2023/4/20 10:53
 */
@Service
public class AcidRollingLMN1720ServiceImpl extends ServiceImpl<AcidRollingLMN1720Mapper, AcidRollingLMN1720> implements AcidRollingLMN1720Service {
    @Resource
    private AcidRollingLMN1720Mapper acidRollingLMN1720Mapper;

    @Override
    public ResultData queryAcidRollingLMN1720() {
        List<AcidRollingLMN1720> lmn1720List = acidRollingLMN1720Mapper.selectList(null);
        return ResultData.ResultDataFaultSelf("操作成功",lmn1720List);
    }

    @Override
    public ResultData updateAcidRollingLMN1720(AcidRollingLMN1720Dto dto) {
        Double yp_class = dto.getYp_class();
        Double l = dto.getL();
        Double m = dto.getM();
        Double n = dto.getN();
        if (yp_class == null) {
            return ResultData.ResultDataFaultSelf("参数有误,请检查参数",-1);
        }
        LambdaQueryWrapper<AcidRollingLMN1720> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AcidRollingLMN1720::getYp_class,yp_class);
        AcidRollingLMN1720 acidRollingLMN1720 = acidRollingLMN1720Mapper.selectOne(queryWrapper);
        if (acidRollingLMN1720 != null) {
            acidRollingLMN1720.setL(l);
            acidRollingLMN1720.setM(m);
            acidRollingLMN1720.setN(n);
            int flag = acidRollingLMN1720Mapper.update(acidRollingLMN1720, queryWrapper);
            if (flag == 1) {
                return ResultData.ResultDataFaultSelf("操作成功",1);
            }
        }
        return  ResultData.ResultDataFaultSelf("操作失败",-1);
    }
}
